package com.hotec.PROJECT_NAME.modules.sys.controller;

import com.hotec.PROJECT_NAME.component.basic.BaseController;
import com.hotec.PROJECT_NAME.component.basic.ConstantKey;
import com.hotec.PROJECT_NAME.component.basic.JsonContent;
import com.hotec.PROJECT_NAME.modules.sys.service.SysMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedHashMap;

/**
 * @author llb
 * @date
 */
@RestController
@RequestMapping("sys/message")
public class SysMessageController extends BaseController {
    @Autowired
    private SysMessageService service;

    @GetMapping("/trust/top5")
    public JsonContent trustQueryTop5 (){
        return this.success(service.trustQueryTop5());
    }

    @GetMapping("/trust/newCount")
    public JsonContent trustNewCount (){
        return this.success("查询成功", service.trustNewCount(), false);
    }

    @GetMapping("/shop/top5")
    public JsonContent shopQueryTop5 (){
        return this.success(service.shopQueryTop5());
    }

    @GetMapping("/shop/newCount")
    public JsonContent shopNewCount (){
        return this.success("查询成功", service.shopNewCount(), false);
    }

    @PostMapping("/shop/page")
    public JsonContent shopQueryPage (@RequestParam(required = false, value = "pageNum", defaultValue = ConstantKey.DEFAULT_PAGE_NUM) Integer pageNum,
                                 @RequestParam(required = false, value = "pageSize", defaultValue = ConstantKey.DEFAULT_PAGE_SIZE) Integer pageSize,
                                 @RequestBody LinkedHashMap entity){

        return this.success(service.shopQueryPage(pageNum, pageSize, entity));
    }

    @PostMapping("query")
    public JsonContent query (@RequestParam(required = false, value = "pageNum", defaultValue = ConstantKey.DEFAULT_PAGE_NUM) Integer pageNum,
                                 @RequestParam(required = false, value = "pageSize", defaultValue = ConstantKey.DEFAULT_PAGE_SIZE) Integer pageSize,
                                 @RequestBody LinkedHashMap entity){

        return this.success(service.queryByPage(entity, pageNum, pageSize));
    }
}
